package com.gxa.retail_admin.controller;

import com.gxa.common.vo.JsonResult;
import com.gxa.common.vo.ResultVo;
import com.gxa.modules.pojo.Account;
import com.gxa.modules.pojo.Invest;
import com.gxa.modules.pojo.Member;
import com.gxa.modules.service.MemberService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@Controller
@Api(value = "测试数据",tags = "会员接口—陈峰江")
public class MemberController {
    @Autowired(required = false)
    private MemberService memberService;
//    1.会员列表

    /**
     * 分页查询所有会员信息
     * @param page
     * @param limit
     *
     */
    @GetMapping("/queryMember")
    @ApiOperation(value = "会员查询接口",notes = "分页查询所有会员信息",httpMethod = "GET",response = JsonResult.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400,message = "参数接口问题"),
            @ApiResponse(code = 405,message = "方法不允许"),
            @ApiResponse(code = 500,message = "后端问题"),
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "limit",value = "每页显示条数",paramType = "query",dataType = "String")
    })
    @ResponseBody
    @RequiresPermissions("会员列表")
    public JsonResult queryMember(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) {

        return memberService.queryMember(page,limit);
    }

    /**
     * 卡号(会员号)查询会员信息
     * @param member_cd
     *
     */
    @GetMapping("/queryMemberByNumber")
    @ApiOperation(value = "按会员号查询接口",notes = "查询会员信息",httpMethod = "GET",response = JsonResult.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400,message = "参数接口问题"),
            @ApiResponse(code = 405,message = "方法不允许"),
            @ApiResponse(code = 500,message = "后端问题"),
    })
    @ApiImplicitParam(name = "member_cd",value = "会员卡号",paramType = "query",dataType = "String")
    @ResponseBody
    @RequiresPermissions("会员列表")
    public JsonResult queryMemberByNumber(Integer member_cd){

        return memberService.queryMemberByNumber(member_cd);
    }

    /**
     * 添加会员
     * @param member
     *
     */
    @PostMapping("/addMember")
    @ApiOperation(value = "添加会员接口",notes = "传递实体添加会员",httpMethod = "POST",response = ResultVo.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400,message = "参数接口问题"),
            @ApiResponse(code = 405,message = "方法不允许"),
            @ApiResponse(code = 500,message = "后端问题"),
    })
    @ResponseBody
    @RequiresPermissions("会员列表")
    public ResultVo addMember(@RequestBody @ApiParam(name = "member",value = "会员实体")Member member){

        return memberService.addMember(member);
    }

    /**
     * 修改会员密码
     * @param member_cd,
     * @return
     */
    @PostMapping("/updateMemberPwd")
    @ApiOperation(value = "会员密码修改接口",notes = "会员密码修改接口",httpMethod = "POST",response = JsonResult.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400,message = "参数接口问题"),
            @ApiResponse(code = 405,message = "方法不允许"),
            @ApiResponse(code = 500,message = "后端问题"),
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "member_cd",value = "会员卡号",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "newPwd",value = "新密码",paramType = "query",dataType = "String")
    })
    @ResponseBody
    @RequiresPermissions("会员列表")
    public ResultVo updateMemberPwd(Integer member_cd,String newPwd){

        return  memberService.updateMemberPwd(member_cd,newPwd);
    }

    /**
     * 修改会员信息(编辑功能)
     * @param member
     *
     */
    @PostMapping("/editMember")
    @ApiOperation(value = "编辑会员信息",notes = "修改会员信息",httpMethod = "POST",response = JsonResult.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400,message = "参数接口问题"),
            @ApiResponse(code = 405,message = "方法不允许"),
            @ApiResponse(code = 500,message = "后端问题"),
    })
    @ResponseBody
    @RequiresPermissions("会员列表")
    public ResultVo editMember(@RequestBody @ApiParam(name = "member",value = "会员实体")Member member){

        return  memberService.editMember(member);
    }


//    2.充值记录
    @GetMapping("/queryInvest")
    @ApiOperation(value = "充值查询接口",notes = "分页查询所有充值信息",httpMethod = "GET",response = JsonResult.class)
    @ApiResponses({
            @ApiResponse(code = 200,message = "查询成功"),
            @ApiResponse(code = 400,message = "参数接口问题"),
            @ApiResponse(code = 405,message = "方法不允许"),
            @ApiResponse(code = 500,message = "后端问题"),
    })
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "limit",value = "每页显示条数",paramType = "query",dataType = "String")
    })
    @ResponseBody
    @RequiresPermissions("充值记录")
    public JsonResult queryInvest(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit) {

        return memberService.queryInvest(page,limit);
    }


    /**
     * 订单号搜索
     * @param invest_number
     * @return
     */
    @GetMapping(value = "/searchInvest")
    @ApiOperation(value = "订单号搜索",notes = "按订单号搜索",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数,默认为1",paramType = "query",required = false,dataType ="String" ),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数,默认为10",paramType = "query",required = false,dataType ="String" ),
            @ApiImplicitParam(name = "invest_number",value = "订单号搜索",paramType = "query",required = false,dataType ="String" )
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code = 405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("充值记录")
    public JsonResult searchInvest(Integer invest_number){

        return memberService.searchInvest(invest_number);
    }

    /**
     * 查询今日新增
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/queryTodayInvest")
    @ApiOperation(value = "今日新增接口",notes = "查询今日新增订单",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = false),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code=405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("充值记录")
    public JsonResult queryTodayInvest(@RequestParam(defaultValue = "1")Integer currentPage,@RequestParam(defaultValue = "10")Integer pageSize) {

        return memberService.queryTodayInvest(currentPage,pageSize);
    }
    /**
     * 查询昨日新增
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/queryYesterdayInvest")
    @ApiOperation(value = "昨日新增接口",notes = "查询昨日新增订单",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = false),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code=405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("充值记录")
    public JsonResult queryYesterdayInvest(@RequestParam(defaultValue = "1")Integer currentPage,@RequestParam(defaultValue = "10")Integer pageSize) {

        return memberService.queryYesterdayInvest(currentPage,pageSize);
    }

    /**
     * 查询本周
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/queryWeekInvest")
    @ApiOperation(value = "本周新增接口",notes = "查询本周新增订单",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = false),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code=405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("充值记录")
    public JsonResult queryWeekInvest(@RequestParam(defaultValue = "1")Integer currentPage,@RequestParam(defaultValue = "10")Integer pageSize){

        return memberService.queryWeekInvest(currentPage,pageSize);
    }

    /**
     * 查询本月新增
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GetMapping(value = "/queryMonthInvest")
    @ApiOperation(value = "本月新增接口",notes = "查询本月新增订单",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = false),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code=405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("充值记录")
    public JsonResult queryMonthInvest(@RequestParam(defaultValue = "1")Integer currentPage,@RequestParam(defaultValue = "10")Integer pageSize){

        return  memberService.queryMonthInvest(currentPage,pageSize);
    }

    /**
     * 时间段查询订单
     * @param beforeTime
     * @param afterTime
     * @return
     */
    @GetMapping(value = "/queryBetweenTimeInvest")
    @ApiOperation(value = "范围时间查询",notes = "查询范围时间订单",httpMethod = "GET", response = JsonResult.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页显示条数",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "beforeTime",value = "前一个时间",paramType = "query",dataType = "String",required = false),
            @ApiImplicitParam(name = "afterTime",value = "后一个时间",paramType = "query",dataType = "String",required = false),
    })
    @ApiResponses({
            @ApiResponse(code=200,message = "success"),
            @ApiResponse(code=404,message = "找不到页面，接口或参数错误"),
            @ApiResponse(code=405,message = "方法不允许"),
            @ApiResponse(code=500,message = "后台错误"),
    })
    @ResponseBody
    @RequiresPermissions("充值记录")
    public JsonResult queryBetweenTimeInvest(@RequestParam(defaultValue = "1")Integer currentPage,@RequestParam(defaultValue = "10")Integer pageSize,String beforeTime,String afterTime){

        return memberService.queryBetweenTimeInvest(currentPage,pageSize,beforeTime,afterTime);
    }

}
